package com.admin.education.models;

import com.admin.education.repositories.Identifiable;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "user_answer_sheet")
@EntityListeners(AuditingEntityListener.class)
@Data
public class UserAnswerSheet implements Serializable, Identifiable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name = "name")
    @Length(max = 1024)
    @NotBlank
    @NotNull
    private String name;
    @Column(name = "begin_time")
    private Date beginTime;
    @Column(name = "end_time")
    private Date endTime;
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userAnswerSheet")
    @JSONField(serialize = false)
    private List<UserAnswerSheetQuestion> userAnswerSheetQuestions;
    @ManyToOne(cascade = CascadeType.DETACH)
    @NotNull
    @JSONField(serialize = false)
    private Templates templates;
    @OneToOne
    @NotNull
    @JSONField(serialize = false)
    private UserInformation userInformation;
    @Column(name = "total_mark")
    private BigDecimal totalMark;
    @Column(name = "create_time")
    private Date createTime;
    @Column(name = "template_mark")
    private BigDecimal templateMark;
    @Column(name = "correct_number_of_questions")
    private int correctNumberofQuestions;
    @Column(name="")
    private String designationName;
}
